package com.fyyg.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import com.fyyg.dal.TBusiPackageMapper;
import com.fyyg.dal.TBusiProductMapper;
import com.fyyg.interfaces.TBusiProductPkgService;
import com.fyyg.model.ProductBuy;
import com.fyyg.model.TBusiPackage;
import com.fyyg.model.TBusiProduct;
import com.google.common.collect.Lists;

@Service("TBusiProductPkgService")
public class TBusiProductPkgServiceImpl implements TBusiProductPkgService {

	@Resource TBusiProductMapper tBusiProductMapper;
	
	@Resource TBusiPackageMapper tBusiPackageMapper;
	
	@Override
	public ProductBuy queryProPkg() {
		ProductBuy productBuy = new ProductBuy();
		List<TBusiProduct> tBusiProducts = tBusiProductMapper.queryEventPro();
		if(CollectionUtils.isNotEmpty(tBusiProducts)) {
			productBuy.setProList(tBusiProducts);
			List<TBusiPackage> tBusiPackages = Lists.newArrayList();
			tBusiProducts.forEach(f->{
				productBuy.setProId(f.getProId());
				TBusiPackage tBusiPackage = tBusiPackageMapper.selectByProId(f.getProId());
				if(null != tBusiPackage) {
					productBuy.setPkgId(tBusiPackage.getPkgId());
					tBusiPackages.add(tBusiPackage);
				}
			});
			productBuy.setPkgList(tBusiPackages);
		}
		return productBuy;
	}

	@Override
	public int deleteByPrimaryKey(Integer pkgId) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(TBusiPackage record) {
		return tBusiPackageMapper.insert(record);
	}

	@Override
	public TBusiPackage selectByPrimaryKey(Integer pkgId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public TBusiPackage selectByProId(Integer proId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<TBusiPackage> selectAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKey(TBusiPackage record) {
		// TODO Auto-generated method stub
		return 0;
	}

}
